package com.bjpowernode.vo;

import com.bjpowernode.core.ResultCode;
import lombok.Getter;

//统一返回格式的实现方法类（真正要返回给controlle，前端的）
@Getter
public class ResultJson<T> {
    private  Integer code;
    private  T content;
    private  String message;

    //构造方法
    public ResultJson(Integer code, T content, String message) {
        this.code = code;
        this.content = content;
        this.message = message;
    }

    //返回controller层调用显示响应结果的方法
    public static <T> ResultJson<T> getInstance(ResultCode resultCode,T content,String message) {
        return new ResultJson<>(resultCode.getCode(),content,message);
    }

    public static <T> ResultJson<T> success(T content,String message) {
        return getInstance(ResultCode.SUCCESS,content,message);
    }

    public static <T> ResultJson<T> success(T content) {
        return success(content,null);
    }

    public static <T> ResultJson<T> failed(T content,String message) {
        return getInstance(ResultCode.FAILED,content,message);
    }

    public static <T> ResultJson<T> failed(String message) {
        return failed(null,message);
    }
}
